import axios from '@/utils/axios'

export function getFilePage(params) {
  return axios({
    url: '/file/page',
    method: 'get',
    params
  })
}

export function getFileList() {
  return axios({
    url: '/file/list',
    method: 'get'
  })
}

export function uploadFile(data) {
  return axios({
    url: '/file/upload',
    method: 'post',
    transformRequest: [function(data) {
      // 对 data 进行任意转换处理
      return data
    }],
    data
  })
}

export function uploadAvatar(data) {
  return axios({
    url: '/file/upload/avatar',
    method: 'post',
    transformRequest: [function(data) {
      // 对 data 进行任意转换处理
      return data
    }],
    data
  })
}

export function updateFileState(data) {
  return axios({
    url: '/file/state',
    method: 'post',
    data
  })
}

export function downloadFile(id) {
  return axios({
    url: '/file/download_' + id,
    method: 'get',
    responseType: 'blob'
  })
}

export function deleteFile(id) {
  return axios({
    url: '/file/d_' + id,
    method: 'get'
  })
}
